<?php $basePath=$this->basePath;?>
<?php $baseUrl=$this->baseUrl;?>
<script> 
var BASE_PATH = '<?php echo $basePath;?>';
var BASE_URL = '<?php echo $baseUrl;?>';
</script>
<html lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
	</head>
	<body>
		<div class="bg-cover"></div>
		<div id="wrapper" class="container">			
			<? if(isset($this->existtoken)&& ($this->existtoken==1)){?>	
			<section class="login">
				<form class="form-login" role="form">
				<h1>Reset Your Password</h1>				
					
					<div class="login_sub login-area">
						<div class="login_psw input-group">
							<input type="password" id="newpwd" name="newpwd" class="form-control input-lg" placeholder="Your new password"/>
						</div>
						<div class="login_psw input-group">
							<input type="password" id="confirm-pwd" name="confirm-pwd" class="form-control input-lg" placeholder="Your confirm password"/>
						</div>
						<div class="sign_in form-group">
							<a href="#" onclick="return updatePassword();" role="button" class="btn btn-lg btn-danger btn-block">Submit</button>
							<div id="loading" style="display:none;float:right;margin-right:30px;"><img src="<?php echo $this->basePath() ?>/images/loading_image.gif" /></div>
						</div>	
					</div>									
					<span id="confirmerrormsg" style="margin-left:70px;color:red"><span>
					<input type="hidden" id="hidtoken" name="hidtoken" value="<?echo $_GET['token'];?>"/>
			</form>
			</section>	
			<?}else{?>
				<section class="forgetUrl_exipred">
				<div style="padding-top:80px !important;">Your gotten URL is expired. Please try once again...</div>
				</section>	
			<?}?>					
		</div>
		
	</body>
</html>
<div class="clear"></div>  
<script>	
	function updatePassword(){	
		var flag=true;
		var token=$('#hidtoken').val();			
		var passwrd=$("#newpwd").val();
		var cnfpwrd=$("#confirm-pwd").val();		
		if(passwrd==""&& cnfpwrd==""){
			$("#confirmerrormsg").html('*Your new password is required');
			flag=false;
			$("#newpwd").focus();
		}		
		if(flag==false){ 
				return false;
		}else{			
			if(passwrd==cnfpwrd){
			$('#loading').show();
				$.ajax({
					type:'POST',
					url:BASE_PATH+'setnepassword',
					data:{cnfpwrd:cnfpwrd,token:token},
					success: function(data){
						$('#loading').hide();
						if(data.output=='success'){	
							$("#confirmerrormsg").html('Your password successfully updated');							
							 window.location="<? echo $this->Url('home')?>";								
						}else{
							$("#confirmerrormsg").html('Already update your password');
						}
					}
				});
			}else{
				$("#confirmerrormsg").html('Your password do not match');
				$("#confirm-pwd").focus();
			}
		}		
	}	
</script>
